#include <iostream>
#include <stdio.h>
#include <time.h>
using namespace std;
void main()
{
	srand(time(NULL));
	int line , column;
	cout<<"enter line";
	cin>>line;
	cout<<"enter column";
	cin>>column;

	int **pmas=new int *[line];
	for(int i=0;i<column;i++)
	{
		pmas[i]=new int [column];
	}
	for(int i=0;i<line;i++)
	{
		for(int j=0;j<column;j++)
		{
		pmas[i][j]=rand()%10;
		cout<<pmas[i][j]<<" ";
		}
		cout<<endl;
	}
	int c;
	cout<<"enter 1 for line 2 for column\n";
	cin>>c;
		if(c==1)
		{
			int num;
			cout<<"enter numer of line\n";
			cin>>num;
			int **q=new int *[line+1];
			for(int i=0;i<line+1;i++)
				{
					q[i]=new int [column];
				}
			for(int i=0;i<num;i++)
				{
					for(int j=0;j<column;j++)
					{
					q[i][j]=pmas[i][j];
					cout<<pmas[i][j]<<" ";
					}
					cout<<endl;
				}
			int i=num; 
				
            for (int j=0; j<column; j++)
				{
					q[i][j]=rand()%10;
					cout <<q[i][j] <<" ";
				}
			cout<<endl;
				for (int i=num; i<line; i++)
					{
						for (int j=0; j<column; j++)
						{
							q[i][j]=pmas[i][j];
							cout <<q[i][j] <<" ";
						}
						cout <<endl;
					}
				for (int i=0; i<line+1; i++)
					{
						delete[]q[i];
					}
					delete[]q;
		}
if(c==2)
{ 
			int nomer_stolba;
        do
        {
        cout <<" enter number of column" <<endl;       
        cin >>nomer_stolba;
        cout <<"\n";
        }
        while (nomer_stolba<=0);
 
        int **q;
        q=new int * [line];
        for (int i=0; i<line; i++)
        {
            q[i]=new int [column+1];
        }
 
        
      int i=0;
      int j;
        do
        {
        for (j=0; j<nomer_stolba; j++)
        {
            q[i][j]=pmas[i][j];
            cout <<q[i][j] <<" ";
        }
 
        j=nomer_stolba;
 
        q[i][j]=rand()%10;
        cout <<q[i][j] <<" ";
 
        for (j=nomer_stolba+1; j<column+1; j++)
        {
            q[i][j]=pmas[i][j-1];
            cout <<q[i][j] <<" ";
        }
        i++;
        cout <<endl;
 
        }
        while (i<line);
	for (int i=0; i<line; i++)
		 { 
		 delete[] q[i];
		 }   
		delete[] q;
	}
	

	 for (int i=0; i<line; i++)
	  {
		  delete[] pmas[i];
	  }
		  delete[] pmas;

	
}